<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<title>选课系统-登陆界面</title>
		<link href="resources/css/bootstrap.css" rel="stylesheet">
		<link href="resources/css/bootstrap-responsive.css" rel="stylesheet">
		<link href="resources/css/styles.css" rel="stylesheet">
		<script src="resources/js/jquery.js"></script>
		<script>
	$(function() {
		$("input:button").click(function() {
			window.open("register.do");
		});
		$("a").click(function() {
			var schoolNo = $("input:eq(0)").val();
			var pwd = $("input:eq(1)").val();
			if (schoolNo == "" && pwd == "") {
				alert('用户名和密码不能为空！');
			} else {
				$.ajax({
					url : "login.do",
					type : "post",
					dataType : "json",
					data : {
						"schoolNo" : schoolNo,
						"password" : pwd
					},
					success : function(json) {
						if (!json.isSuccess) {
							alert("用户名或密码错误！");
						}
						if (json.isSuccess) {
							if(json.role=="2"){
								window.open("adminSelect.do");
								//$("a").attr("href","adminSelect.do");
							}else if(json.role=="1")
								//$("a").attr("href","select.do");
								window.open("select.do");
							else
								window.open("teacherhome.do");
								//$("a").attr("href","teacherhome.do");
						}
					}
				});
			}
		});
	});
</script>
	</head>

	<body>
		<div class="container-fluid" data-isSuccess=${isSuccess}>
			<form class="form-signin" action="login.do" method="post">
				<h2 class="form-signin-heading">
					Please sign in
				</h2>
				<input name="schoolNo" type="text" placeholder="SchoolNO"
					class="input-block-level">
				<input name="password" type="password" placeholder="Password"
					class="input-block-level">
				<label class="checkbox">
					<input type="checkbox" value="remember-me">
					Remember me
				</label>
				<a class="btn btn-large btn-primary">Sign in</a>
				<input type="button" value="register"
					class="btn btn-large btn-primary" style="margin-left: 10px" />
			</form>
		</div>
	</body>
</html>
